/******************************************************************************************************
Copyright (C) 2016 Mestrelab Research S.L. All rights reserved.

This file is part of the MNova scripting toolkit.

Authorized users of MNova Software may use this file freely, but this file is provided AS IS
with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE.
*****************************************************************************************************/

/*globals mainWindow*/
/*jslint plusplus: true, indent: 4*/

function NMRUtils() {
	"use strict";
}

NMRUtils.resfreq = function (aNT, aHF) {
	"use strict";

	var aVal, reffrq;

	reffrq = {
		H1: 1.0,
		H2: 0.153506,
		H3: 1.066639,
		He3: 0.761790,
		Li6: 0.147161,
		Li7: 0.388637,
		Be9: 0.140518,
		B10: 0.107437,
		B11: 0.320839,
		C13: 0.251450,
		N14: 0.072264,
		N15: 0.101368,
		O17: 0.135564,
		F19: 0.940940,
		Ne21: 0.078943,
		Na23: 0.264519,
		Mg25: 0.061216,
		Al27: 0.260568,
		Si29: 0.198672,
		P31: 0.404808,
		S33: 0.076760,
		Cl35: 0.097979,
		Cl37: 0.081557,
		K39: 0.046664,
		K41: 0.025613,
		Ca43: 0.067300,
		Sc45: 0.242917,
		Ti47: 0.056376,
		Ti49: 0.056391,
		V50: 0.099703,
		V51: 0.263030,
		Cr53: 0.056525,
		Mn55: 0.247892,
		Fe57: 0.032378,
		Co59: 0.237271,
		Ni61: 0.089360,
		Cu63: 0.265155,
		Cu65: 0.284037,
		Zn67: 0.062568,
		Ga69: 0.240014,
		Ga71: 0.304967,
		Ge73: 0.034883,
		As75: 0.171226,
		Se77: 0.190715,
		Br79: 0.250539,
		Br81: 0.270065,
		Kr83: 0.038476,
		Rb85: 0.096549,
		Rb87: 0.327204,
		Sr87: 0.043338,
		Y89: 0.049002,
		Zr91: 0.092963,
		Nb93: 0.244762,
		Mo95: 0.065170,
		Mo97: 0.066537,
		Tc99: 0.225084,
		Ru99: 0.046051,
		Ru101: 0.051613,
		Rh103: 0.031865,
		Pd105: 0.045761,
		Ag107: 0.040478,
		Ag109: 0.046535,
		Cd111: 0.212154,
		Cd113: 0.221932,
		In113: 0.218658,
		In115: 0.219127,
		Sn115: 0.327187,
		Sn117: 0.356323,
		Sn119: 0.372907,
		Sb121: 0.239306,
		Sb123: 0.129592,
		Te123: 0.261697,
		Te125: 0.315498,
		I127:  0.200075,
		Xe129: 0.278102,
		Xe131: 0.082439,
		Cs133: 0.131161,
		Ba135: 0.099344,
		Ba137: 0.111130,
		La138: 0.131943,
		La139: 0.141257,
		Pr141: 0.306170,
		Nd143: 0.054473,
		Nd145: 0.033556,
		Sm147: 0.041675,
		Sm149: 0.034356,
		Eu151: 0.248618,
		Eu153: 0.109736,
		Gd155: 0.030696,
		Gd157: 0.040255,
		Tb159: 0.240379,
		Dy161: 0.034376,
		Dy163: 0.048194,
		Ho165: 0.211353,
		Er167: 0.028846,
		Tm169: 0.082709,
		Yb171: 0.174993,
		Yb173: 0.048684,
		Lu175: 0.114185,
		Lu176: 0.081049,
		Hf177: 0.040585,
		Hf179: 0.025497,
		Ta181: 0.119896,
		W183:  0.041664,
		Re185: 0.225246,
		Re187: 0.227516,
		Os187: 0.022823,
		Os189: 0.077654,
		Ir191: 0.017988,
		Ir193: 0.019537,
		Pt195: 0.214968,
		Au197: 0.017688,
		Hg199: 0.179109,
		Hg201: 0.066115,
		Tl203: 0.571232,
		Tl205: 0.576838,
		Pb207: 0.209206,
		Bi209: 0.160693,
		Po209: 0.243478,
		Pa231: 0.239899,
		U235: 0.018414
	};

	if (!(aNT.charAt(0).match(/[a-z]/i))) {
		// 'usual' nomenclature needs to be reversed:  15N => N15, 31P => P31, etc
		aVal = aNT.match(/[a-zA-Z]+/g) + aNT.match(/\d+/g);
	} else {
		// VnmrJ-style nomenclature
		aVal = aNT;
	}

	return reffrq[aVal] * aHF;
};
